import { FrameworkConfigurator } from '../extension/scripts/framework-config';

const gulp = require('gulp');
const debug = require('gulp-debug');

/**
 * 测试
 * @param cb
 */
export function test(cb: Function) {
    const modules =
        'index,archive,config,database,function,language,component-multiple-languages,load,log,network-websocket,network-http,pack,pool-node,reference,scene,timer,ui,variable,widget,component-widget-bind';
    let fconfig = new FrameworkConfigurator('src/framework/config.json');
    fconfig.keepModules(modules.split(','));
    let sources = fconfig.collectSources().map((item, index, input) => {
        return 'src/framework/' + item;
    });
    sources.push(...['declarations/creator.d.ts', 'src/@types/**/*.ts', '../../temp/declarations/**/*.ts']);
    return gulp.src(sources).pipe(debug({ title: 'file:' }));
}

/**
 * 默认构建
 */
export default function build(cb: Function) {
    console.log('请选择一个任务:');
    console.log('构建当前扩展\t', 'buildExtension');
    console.log('构建框架资源\t', 'buildAssets [--modules ModuleList split by ,]');
    console.log('构建游戏包声明\t', 'buildDeclaration [--path BundlePath]');
    cb();
}

export { build as buildExtension } from './extension';
export { build as buildAssets } from './assets';
export { build as buildDeclaration } from './declaration';
